home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / MMmalloc / MMmalloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.1 KB  |  126 lines

  1. #ifndef __MM_MALLOC_H__
  2. #define __MM_MALLOC_H__
  3. /*
  4.  * MMmalloc.h
  5.  *
  6.  *                    Gianni Mariani  8-Apr-1994
  7.  *
  8.  *    Extra definitions for MMmalloc not found in <malloc.h>
  9.  *
  10.  */
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15. #define mm_size_t        size_t
  16. #define mm_ssize_t        ssize_t
  17.  
  18. /* New mallopt commands                            */
  19. #define M_LOCKASSIGN    200    /* Assign a lock to an arena        */
  20. #define M_USERDATA    201    /* set the user data field        */
  21.  
  22.  
  23. /* These are recycle mmap/munmap entry points.                */
  24. /* Memory to be unreferenced is unmapped using _mm_munmap and mapped    */
  25. /* using _mm_mmapmem.  MMmalloc routines cannot be called inside    */
  26. /* _mm_munmap or _mm_mmapmem.                        */
  27. void    _mm_munmap(
  28.     register char          * p_addr,/* Address to unmap        */
  29.     register mm_size_t            siz,   /* Size of the memory    */
  30.     register mm_size_t            userdata,
  31.     void              * arena
  32. );
  33.  
  34. void    * _mm_mmapmem(
  35.     register char          * p_addr,/* Address to map        */
  36.     register mm_size_t            siz,   /* Size of the memory    */
  37.     register mm_size_t              userdata,
  38.     void              * arena
  39. );
  40.  
  41. #define MM_OFFSETOF( ptype, fld )   (( int )&( ( ( ptype ) 0 )->fld ))
  42. #define    MM_ALIGN( val, aval )    ( 1 + ( ( (val) - 1 ) | ( (aval) - 1 ) ) )
  43.  
  44.  
  45.  
  46. /* ======== MM_CONFIG ================================================= */
  47. /* PURPOSE:
  48.  *    MMmalloc configuration parameters structure
  49.  */
  50.  
  51. typedef struct  MM_CONFIG {
  52.  
  53.     unsigned int    mm_ntopromo;    /* Number of allocations in a slot*/
  54.                     /* before promotion        */
  55.  
  56.     int            mm_asizshft;    /* Number of shifts to get qarena*/
  57.     mm_size_t        mm_nqalist;    /* Number of quick allocators    */
  58.     mm_size_t        mm_maxslots;    /* Maximum number of slots in qblk*/
  59.     mm_size_t        mm_minslots;    /* Minimum number of slots in qblk*/
  60.     mm_size_t        mm_adjfactor;    /* Slot adjustment factor    */
  61. #define MM_ADJSHFT    4
  62. #define MM_ADJFACTOR( fact )    \
  63.     ( (( unsigned )( fact * (float)(1<<MM_ADJSHFT) )) )
  64.     mm_size_t        mm_qblkmult;    /* quick block size multiple    */
  65.     
  66.     mm_size_t        mm_nszmult;    /* Roundup val for normal arena    */
  67. #define MM_NFRELVL    3
  68.     struct mm_level {
  69.     mm_size_t        mm_flindx;    /* Maximum index for this shift*/
  70.     mm_size_t        mm_szshft;    /* Size shift        */
  71.     }            mm_xf[ MM_NFRELVL ];
  72. #define mm_mfreelist    mm_xf[MM_NFRELVL-1].mm_flindx
  73.  
  74.     mm_size_t        mm_zeromalloc;    /* Address given for malloc(0)    */
  75.  
  76.     mm_size_t        mm_maxsrch;    /* maxmimum seeks in the free list*/
  77.     mm_size_t        mm_brkmult;    /* The size of sbrk requests    */
  78.     mm_size_t        mm_minrmdr;    /* The minimum remainder allowed*/
  79.     mm_size_t        mm_gcthresh;    /* Threshold to run garbage collector*/
  80.                     /* needed before we go and activate*/
  81.                     /* Garbage collector        */
  82.     mm_size_t        mm_missthrash;    /* Number of misses in a slot    */
  83.                     /* Before we run thrash prot    */
  84.     mm_size_t        mm_flsearh;    /* Maximum number of free list srchs*/
  85.     mm_size_t        mm_reallthrsh;    /* Realloc size threshold for    */
  86.                     /* ordinary to quick allocs    */
  87.     mm_size_t        mm_nunmaplists;    /* Number of unmap lists - 1    */
  88.     mm_size_t        mm_szunmapshift;/* Unmap list shift.        */
  89.     mm_size_t        mm_unmapalign;    /* Alignment of 'unmap'pable memory*/
  90.     mm_size_t        mm_minunmapsize;/* Minimum size to unmap    */
  91.     mm_size_t        mm_minunmapsrch;/* The size of the minimum free list*/
  92.                     /* to search when mdealloc'ing    */
  93.     mm_size_t        mm_minfreerecy;    /* Minimum memory freed to next recy*/
  94.     mm_size_t        mm_debug_on;    /* Is debugging turned on    */
  95.     mm_size_t        mm_abort_badfree; /* abort on a bad free id true*/
  96.     char        mm_clronfree;    /* Clear on free val        */
  97.     char        mm_valclronfree;/* Clear on free value        */
  98.     char        mm_reportrecy;    /* Report recycle !        */
  99.     mm_size_t        mm_morefill[ 10 ];  /* More expansion room    */
  100.     
  101. } MM_CONFIG;
  102.  
  103.  
  104. extern int        _mm_defaultoptions;
  105. extern MM_CONFIG    _mm_adfltconfig[];
  106. extern int        _mm_nadfltconfig;
  107.  
  108. void        rerecycle( void );
  109.  
  110. struct mallinfo qmallinfo( void );
  111. void        malloc_check( void );
  112. size_t        recycle( void );
  113. void        addmem( void * p_mem, mm_size_t size );
  114.  
  115. struct mallinfo aqmallinfo( void * arena );
  116. void        amalloc_check( void * arena );
  117. size_t        arecycle( void * arena );
  118. void        aaddmem( void * p_mem, mm_size_t size, void * arena );
  119.  
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123.  
  124. #endif /* !__MM_MALLOC_H__ */
  125.  
  126.